import 'package:star_author/utils/statistics/event/backflow_event.dart';
import 'package:star_author/utils/statistics/umeng/umeng.dart';

enum Statistics {
  UM, //友盟
  HuiLiu, //自己
}

//todo:统计工具类
abstract class BaseStatistics {
  login(); //登录
  logout(); //退出
  event(event_name, args); //发送事件
  init(); //初始化
  pageStart(name); //进入页面
  pageEnd(name); //退出页面

}

class StatisticsUtil {
  static BaseStatistics? baseStatistics;

  static initStatistics(Statistics statistics) {
    if (baseStatistics == null) {
      if (statistics == Statistics.UM) {
        baseStatistics = UMStatistics();
      }
    }
  }

  static event(event_name, args) {
    if (args.isEmpty) {
      args = getUMengMap({});
    } else {
      args = getUMengMap(args);
    }

    baseStatistics?.event(event_name, args);
  }

  static init() {
    baseStatistics?.init();
  }

  static login() {
    baseStatistics?.login();
  }

  static logout() {
    baseStatistics?.logout();
  }

  static pageStart(name) {
    baseStatistics?.pageStart(name);
  }

  static pageEnd(name) {
    baseStatistics?.pageEnd(name);
  }
}
